@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">角色管理
                <button class="btn btn-primary ml-2">角色列表</button>
                <button class="btn btn-primary" data-toggle="modal" data-target="#add">添加角色</button>
                @component('components.modal',['title' => '添加角色','url' => '/admin/role','id'=>'add'])
                    <div class="form-group">
                        <label>角色名称</label>
                        <input type="text" required placeholder="请输入角色名称..." name="title" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>角色标识</label>
                        <input type="text" required placeholder="请输入角色标识..." name="name" class="form-control">
                    </div>
                @endcomponent
            </div>
            <div class="card-body">
                <table class="table">
                    <thead>
                    <tr>
                        <th>角色编号</th>
                        <th>角色名称</th>
                        <th>角色标识</th>
                        <th>操作</th>

                    </tr>
                    </thead>
                    <tbody>
                    @foreach($roles as $role)
                        <tr>
                            <td>{{$role['id']}}</td>
                            <td>{{$role['title']}}</td>
                            <td>{{$role['name']}}</td>
                            <td>
                                <div class="btn-group" role="group" aria-label="Basic example">
                                    <button data-toggle="modal" data-target="#roleedit{{$role['id']}}" type="button" class="btn btn-success">编辑</button>
                                    @component('components.modal',['title' => '编辑用户','url' => '/admin/role/'.$role['id'],'id'=>'roleedit'.$role['id'],'method'=>'PATCH'])
                                        <div class="form-group">
                                            <label>角色名称</label>
                                            <input type="text"  value="{{$role['title']}}" name="title" class="form-control">
                                        </div>
                                        <div class="form-group">
                                            <label>角色标识</label>
                                            <input type="text" value="{{$role['name']}}" name="name" class="form-control">
                                        </div>
                                    @endcomponent
                                    <form action="{{route('role.destroy',$role['id'])}}" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-danger ml-2">删除</button>
                                    </form>
                                    <a href="{{route('showpermission',$role['id'])}}" class="btn btn-primary ml-2">权限设置</a>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>

            </div>

        </div>
    </div>
@endsection
